package org.massdgames.thunder.server.domain.strategy;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.massdgames.thunder.server.domain.Card;
import org.massdgames.thunder.server.domain.CardType;
import org.massdgames.thunder.server.domain.Deck;

public class BasicDungeonLoadStrategy implements DungeonLoadStrategy {

    public Deck load(Deck deck) throws IOException {
        Properties properties = new Properties();
        properties.load(new FileInputStream("deck.properties"));
        
        int dungeonCount = new Integer(properties.getProperty("dungeon.count"));

        for (int i = 0; i < dungeonCount; i++) {
            Card dungeonCard = new Card();
            dungeonCard.setCardId(i);
            dungeonCard.setName(properties
                    .getProperty("dungeon." + i + ".name"));
            if (dungeonCard.getName().equalsIgnoreCase("Dungeon Feature")) {
                dungeonCard.setCardType(CardType.DUNGEON_FEATURE_SELECTOR);
            } else {
                dungeonCard.setCardType(CardType.DUNGEON_MONSTER);
            }
            deck.addCard(dungeonCard);
        }
        return deck;
    }
    
}
